﻿/// <reference path="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" />
/// <reference path="/knockout-2.1.0.debug.js"/>

ko.bindingHandlers.flipVisible = {
    init: function (element, valueAccessor) {
        // Start visible/invisible according to initial value
        var shouldDisplay = valueAccessor();
        $(element).toggle(shouldDisplay);
    },
    update: function (element, valueAccessor) {
        // On update, fade in/out
        var shouldDisplay = valueAccessor();
        shouldDisplay ? $(element).fadeIn() : $(element).fadeOut();
    }
};
